package com.by.system.feign;

import com.by.common.core.bean.ResultBean;
import com.by.common.core.response.R;
import com.by.feign.client.UserRemoteClient;
import com.by.feign.dto.UserDto;
import com.by.system.entity.User;
import com.by.system.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserFeignController implements UserRemoteClient {

    @Autowired
    UserService userService;

    @Override
    public ResultBean<UserDto> getById(int id) {
        User user = userService.getById(id);
        UserDto userDto = new UserDto();
        userDto.setId(user.getId());
        userDto.setName(user.getName());
        userDto.setMobile(user.getMobile());
        userDto.setAccount(user.getAccount());
        return R.success("用户信息", userDto);
    }
}
